{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "在项目中引入了部分Opendigger的JS文件， 为了将社区化程度和opendigger中其他指标进行比较。\n",
    "以下代码为统计opendigger中部分其他指标\n",
    "此文件需放在Opendigger/notebook下\n",
    "\n",
    "@author: OS-HUBU/Peng\n",
    "\"\"\"\n",
    "\n",
    "#Activity\n",
    "\n",
    "var openDigger = require('../src/open_digger');\n",
    "var startYear = 2020, startMonth = 1, endYear = 2020, endMonth = 12, x = [];\n",
    "for (let y = startYear; y <= endYear; y++) x.push(`${y}`);\n",
    "openDigger.index.activity.getRepoActivity({repoNames: ['AdguardTeam/AdguardFilters', 'SmartThingsCommunity/SmartThingsPublic','flutter/flutter','elastic/kibana','microsoft/vscode','NixOS/nixpkgs','MicrosoftDocs/azure-docs','webcompat/web-bugs','Homebrew/homebrew-cask','odoo/odoo'], startYear, startMonth, endYear, endMonth, groupBy: '', groupTimeRange: 'month', limit: 10, order: 'DESC' }).then(data => {\n",
    "    openDigger.render.plotly(data.map(row => {\n",
    "        return { x, y: row.activity, mode: 'scatter', name: row.name };\n",
    "    }), {title: `Top10社区化程度仓库的 ${startYear} 年度活跃度`, xaxis: {type: 'repoNames'}});\n",
    "});\n",
    "\n",
    "\n",
    "# Openrank\n",
    "var openDigger = require('../src/open_digger');\n",
    "var startYear = 2020, startMonth = 1, endYear = 2020, endMonth = 12, x = [];\n",
    "for (let y = startYear; y <= endYear; y++) x.push(`${y}`);\n",
    "openDigger.index.openrank.getRepoOpenrank(repoNames: ['AdguardTeam/AdguardFilters', 'SmartThingsCommunity/SmartThingsPublic','flutter/flutter','elastic/kibana','microsoft/vscode','NixOS/nixpkgs','MicrosoftDocs/azure-docs','webcompat/web-bugs','Homebrew/homebrew-cask','odoo/odoo'], startYear, startMonth, endYear, endMonth, groupBy: 'Foundation', groupTimeRange: 'year', limit: -1, order: 'DESC' }).then(data => {\n",
    "    openDigger.render.plotly(data.map(row => {\n",
    "        return { x, y: row.openrank, mode: 'scatter', name: row.name };\n",
    "    }), {title: `Top10社区化程度仓库的 ${startYear} 年的影响力`, xaxis: {type: 'repoNames'}});\n",
    "});\n",
    "\n",
    "#Sql方式\n",
    "SELECT repo_name , SUM(openrank) AS total_openrank \n",
    "From gh_repo_openrank gro WHERE repo_name IN('AdguardTeam/AdguardFilters','SmartThingsCommunity/SmartThingsPublic','flutter/flutter','elastic/kibana',\n",
    "'microsoft/vscode','NixOS/nixpkgs','MicrosoftDocs/azure-docs','webcompat/web-bugs','Homebrew/homebrew-cask','odoo/odoo'\n",
    ") AND created_at <= '2021-01-01 08:00:00' AND created_at >= '2020-01-01 08:00:00' GROUP BY repo_name;"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}